local skill = fk.CreateSkill{
  name = "#tea__chenglie_active"
}
local U = require "packages/utility/utility"
---@type ActiveSkillSpec
local chenglie_active = {
  prompt = "chenglie_active_prompt",
  target_num = 1,
  card_num = 1,
  can_use = Util.FalseFunc,
  expand_pile = function (self, player)
    return player:getCardIds(Player.Judge)
  end,
  card_filter = function(self, player, to_select, selected)
    return #selected == 0
    and (Fk:currentRoom():getCardArea(to_select) == Player.Equip or table.contains(Self:getCardIds(Player.Judge), to_select))
  end,
  target_filter = function(self, player, to_select, selected, selected_cards)
    return #selected == 0 and #selected_cards == 1 and to_select ~= Self.id and
    player:canMoveCardInBoardTo(to_select, selected_cards[1])
  end,
  on_use = function(self, room, effect)
    local player = effect.from
    local target = effect.tos[1]
    local cards = effect.cards or {}
    if #cards == 1 then
      if room:getCardArea(effect.cards[1]) == Player.Equip then
        room:moveCardIntoEquip(target, effect.cards[1], self.name, true, player)
      elseif room:getCardArea(effect.cards[1]) == Player.Judge then
        room:moveCardTo(effect.cards[1], Player.Judge, target, fk.ReasonJustMove, self.name, nil, true, player.id)
      end
      if not target.dead and target:isWounded() then
        room:recover{
          who = target,
          num = 1,
          recoverBy = player,
          skillName = self.name,
        }
      end
    end
  end,
}
skill:addEffect("active", chenglie_active)
return skill